﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Text;

namespace Eacademy.Library.Helpers
{
    public static class PasswordHelper
    {
        //Global salt
        //private static string _salt = "77517e11-3102-4b3d-a915-b339e7b712a2";

        public static string ComputeHash(string password, string salt)
        {
            //User salt
            //_salt = _salt + salt;
            
            SHA1 sha1 = new SHA1CryptoServiceProvider();

            byte[] hashValue = sha1.ComputeHash(System.Text.Encoding.Unicode.GetBytes(password + salt));

            StringBuilder result = new StringBuilder();

            foreach (byte value in hashValue)
            {
                result.Append(String.Format("{0,2:X2}", value));
            }

            return result.ToString();
        }
    }

}